﻿using System.Net;

namespace PhoneNetTools.Dns.Records
{
    /// <summary>
    /// A derived resource record class to handle entries of type <c>A</c>.
    /// </summary>
    public sealed class ResourceRecordA : GenericResourceRecord
    {
        /// <summary>
        /// Gets the IP address that is converted from the raw data contained in the resource record.
        /// </summary>
        public IPAddress IPAddress
        {
            get
            {
                if (Data == null || DataLength < 4)
                {
                    return null;
                }

                return new IPAddress(Data);
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceRecordA"/> class and sets the type to <c>A</c>.
        /// The class is set to <c>IN</c>.
        /// </summary>
        public ResourceRecordA()
        {
            QType = QType.A;
        }
    }
}